using System;
using System.Collections.Generic;
using System.Text;

using System.Drawing;

namespace BPMN.MainWindow
{
   public abstract class ConnectingObject:Figure
    {
        protected FlowObject startFigure;
        protected FlowObject endFigure;

    }
    class ConnectingMessage : ConnectingObject
    {
        public ConnectingMessage(FlowObject startFigureV,FlowObject endFigureV)
        {
            startFigure = startFigureV;
            endFigure = endFigureV;
        }
        public override void Draw(System.Drawing.Graphics graphics, System.Drawing.Pen pen, System.Drawing.Brush brush, System.Drawing.PointF offset)
        {
            PointF beginLine = new Point();
            PointF endLine = new Point();
            foreach (HotSpot hotSpot in startFigure.objects )
            {
                if (hotSpot.ConnectingObject ==this  ) 
                {
                    beginLine = new PointF(startFigure.objects[hotSpot].Location.X,startFigure.objects[hotSpot].Location.Y);
                }

            }
            foreach (HotSpot hotSpot in endFigure.objects)
            {
                if (hotSpot.ConnectingObject == this)
                {
                    endLine = new PointF(endFigure.objects[hotSpot].Location.X, endFigure.objects[hotSpot].Location.Y);
                }
            }
            graphics.DrawLine(pen, startFigure.Location, endFigure.Location);
        }
    }       
    
    class ConnectingSequence : ConnectingObject
    {
        public ConnectingSequence(FlowObject startFigureV,FlowObject endFigureV)
        {
            startFigure = startFigureV;
            endFigure = endFigureV;
        }
        public override void Draw(System.Drawing.Graphics graphics, System.Drawing.Pen pen, System.Drawing.Brush brush, System.Drawing.PointF offset)
        {

            PointF beginLine = new Point();
            PointF endLine = new Point();

            foreach (HotSpot hotSpot in startFigure.objects )
            {
                if (hotSpot.ConnectingObject ==this  ) 
                {
                    beginLine = new PointF(startFigure.objects[hotSpot].Location.X,startFigure.objects[hotSpot].Location.Y);
                }

               // if (hotSpot==startFigure.objects)
            }
            foreach (HotSpot hotSpot in endFigure.objects)
            {
                if (hotSpot.ConnectingObject == this)
                {
                    endLine = new PointF(endFigure.objects[hotSpot].Location.X, endFigure.objects[hotSpot].Location.Y);
                }
            }
            graphics.DrawLine(pen, startFigure.Location, endFigure.Location);
        }
    }
    class ConnectingAssociation : ConnectingObject
    {
        public ConnectingAssociation(FlowObject startFigureV, FlowObject endFigureV)
        {
            startFigure = startFigureV;
            endFigure = endFigureV;
            startFigure.objects[0].ConnectingObject = this;
            endFigure.objects[3].ConnectingObject = this;
        }
        public override void Draw(System.Drawing.Graphics graphics, System.Drawing.Pen pen, System.Drawing.Brush brush, System.Drawing.PointF offset)
        {

            PointF beginLine = new Point(-1,-1);
            PointF endLine = new Point(-1, -1);
            foreach (HotSpot hotSpot in startFigure.objects )
            {
                if (hotSpot.ConnectingObject ==this  ) 
                {
                    beginLine = new PointF(startFigure.objects[hotSpot].Location.X,startFigure.objects[hotSpot].Location.Y);
                }

            }
            foreach (HotSpot hotSpot in endFigure.objects)
            {
                if (hotSpot.ConnectingObject == this)
                {
                    endLine = new PointF(endFigure.objects[hotSpot].Location.X, endFigure.objects[hotSpot].Location.Y);
                }
            }

           graphics.DrawLine(pen, beginLine, endLine);

            
        }
    }

    
}